import QtQuick
import QtQuick.Controls
import QtQuick.Layouts


ApplicationWindow {
    width: screenWidth
    height: screenHeight
    visible: true
    title: qsTr("CNC_Double_Head_Saws(Horizontal)")

    // visibility:"Windowed"   // 全屏显示应用程序
    visibility:"FullScreen"   // 全屏显示应用程序

    //显示到副屏
    x: Qt.application.screens[1].virtualX
    y: Qt.application.screens[1].virtualY

    property real screenWidth : 1920
    property real screenHeight : 1080

    property bool testFlag: false

    Component.onCompleted: {
        rootLoader.source = "Manual_Process_Window.qml"
    }

    A_NumberKeyboard{
        id: root_ManagerKeyboard
    }

    Item{
        id: root
        anchors.fill: parent        
    }

    SideBar{        // 侧边栏

    }

    TopBar{         // 顶部操作栏
        anchors.left: root.left
        anchors.leftMargin: 150
        anchors.top: root.top
    }

    Warning_Message_Popup_Window{       // 报警弹窗
        anchors.left: root.left
        anchors.leftMargin: 150
        anchors.top: root.top
    }

    Loader{     // 根目录加载
        id: rootLoader
        anchors.top: root.top
        anchors.topMargin: 70
        anchors.left: root.left
        anchors.leftMargin: 150

        onSourceChanged: {
            console.log("根目录当前加载: "+ source)
        }
    }

    Popup{      // 登录密码输入弹窗
        id: passwdManager
        anchors.centerIn: parent
        width: 1200
        height: 650
        closePolicy : Popup.NoAutoClose
        modal:  true
        dim: true

        background: Rectangle{
            radius: 10
            border.width: 1
            color: "white"

            Text{
                id: managerText
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.top: parent.top
                anchors.topMargin: 100
                font.pixelSize: Cpp_Language.CurrentLanguage === 1 ? 80 : Cpp_Language.CurrentLanguage === 2 ? 50 : Cpp_Language.CurrentLanguage === 3 ? 50 : 80
                color: "black"
                text: qsTr("请输入管理密码")
            }

            // Text{
            //     anchors.horizontalCenter: parent.horizontalCenter
            //     anchors.top: parent.top
            //     anchors.topMargin: 240
            //     font.pixelSize: Cpp_Language.CurrentLanguage === 1 ? 80 : Cpp_Language.CurrentLanguage === 2 ? 50 : Cpp_Language.CurrentLanguage === 3 ? 50 : 80
            //     color: "red"
            //     text: qsTr("默认为: 2222 ")
            // }

            A_NumberInput{
                anchors.horizontalCenter: parent.horizontalCenter
                anchors.top: parent.top
                anchors.topMargin: 240
                inputWidth: 300
                inputHeight: 50
                keyboard: root_ManagerKeyboard

                onEditingFinished: function(value)
                {
                    if(value === "2222")
                    {
                        Cpp_PLC.write_into_PLC_Coils(600,true)
                        passwdManager.close();
                    }
                    else
                    {
                        managerText.text = qsTr("密码错误,请重新输入")
                    }
                }
            }

            A_Button{
                anchors.bottom: parent.bottom
                anchors.bottomMargin: 20
                anchors.horizontalCenter: parent.horizontalCenter
                contentText_Data: qsTr("关  闭")
                onButtonClicked: {
                    managerText.text = qsTr("请输入管理密码")
                    passwdManager.close();
                }
            }
        }


    }




}
